from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from models import db
from view.course import cour_bp
from view.order import order_bp
from view.students import student_bp
from view.teachers import teacher_bp
from view.common import common_bp
from models.models import *

def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)

    cors = CORS(app)
    db.init_app(app)
    Migrate(app, db)
    app.register_blueprint(teacher_bp)
    app.register_blueprint(student_bp)
    app.register_blueprint(cour_bp)
    app.register_blueprint(order_bp)
    app.register_blueprint(common_bp)

    return app
